package dst.benchmark;

import dataStructures.list.Queue;
import dst.graph.GraphNode;
import java.util.ArrayList;
import time.Timer;

/**
 *
 * @author Shimu
 */
public class TreeBenchMark {

    /*
    private static Graph<String> generateLargeBalancedTree(int totalNodes,
            int branchingFactor) {
        Timer timer = new Timer(true);
        timer.start("Creating balanced tree with " + totalNodes
                + " nodes and " + branchingFactor + " branching factor");

        GraphNode<String> root = new GraphNode<String>("root");
        Queue<GraphNode<String>> queue = new Queue<GraphNode<String>>();
        queue.enqueue(root);
        GraphNode<String> parent;
        ArrayList<GraphNode<String>> children;

        for (int i = 1; i < totalNodes + 1; i++) {
            parent = queue.dequeue();
            children = new ArrayList<GraphNode<String>>(branchingFactor);
            for (int j = 0; j < branchingFactor; j++) {
                children.add(parent.addChild(Integer.toString(i + j)));
            }
            i += branchingFactor - 1;
            for (GraphNode<String> child : children) {
                queue.enqueue(child);
            }
        }

        timer.stop("Finished creating tree");
        return new Graph<String>(root);
    }

    public static void main(String args[]) {
        Timer total = new Timer(true);
        total.start("Benchmarking tree creation and searching");

        Timer timer = new Timer(true);
        int totalNodes = 1500000;
        int branchingFactor = 15;
        Graph<String> tree = generateLargeBalancedTree(totalNodes,
                branchingFactor);

        timer.start("Timing depth-first search of the entire tree");
        System.out.println(tree.depthFirstSearch(Integer.toString(totalNodes)));
        //tree.depthFirstExplore(tree.TREE_TRACER);
        timer.stop("Finished depth-first search of the entire tree");

        timer.start("Timing breadth-first search of the entire tree");
        System.out.println(tree.breadthFirstSearch(Integer.toString(totalNodes)));
        //tree.breadthFirstExplore(tree.TREE_TRACER);
        timer.stop("Finished breadth-first search of the entire tree");

        total.stop("Finished tree creation and searching");
    }*/
}
